package slevnik;

import java.util.List;

/**
 * This class is an interface to manager of items
 * @author Eduard Krak, Martin Penak
 */
public interface ItemManager {

    /**
     * This method adds given item to items table. Works with SQL.
     * @param item to be added
     * @return Item, which was added with generated id.
     * @throws SlevnikException
     */
    public Item addItem(Item item) throws SlevnikException;

    /**
     * This method removes given item from items table. Returns true if
     * item was in the items table and has been removed, false if item hasn't been found.
     * @param item item to be removed
     * @return True if item was found and removed, false otherwise.
     * @throws SlevnikException
     */

    public boolean removeItem(Item item) throws SlevnikException;

    /**
     * This method returns list of all items as item objects from the items table.
     * @param sortingParam parameter used to order Items
     * @param ascending boolean deciding if to sort ascendingly or descendingly
     * @return Set of all items in the table.
     * @throws SlevnikException
     */
    public List<Item> findAllItems(String sortingParam, Boolean ascending) throws SlevnikException;

    /**
     * This method adds given list of items in the items table. Uses method
     * addItem.
     * @param items items to be added
     * @return set of added items
     * @throws SlevnikException
     */
    public List<Item> addItems(List<Item> items) throws SlevnikException;

    /**
     * This method removes all items from items table, so the table is empty.
     * @return true if items have been removed, false otherwise.
     * @throws SlevnikException
     */
    public boolean removeAllItems() throws SlevnikException;

    /**
     * This method finds item with given id
     * @param id id of finding item
     * @return Item with given id
     * @throws SlevnikException
     */
    public Item findItemById(int id) throws SlevnikException;

    /**
     * This method finds list of items selected by city.
     * @param city city user to filter items
     * @param sortingParam parameter used to order Items
     * @param ascending boolean deciding if to sort ascendingly or descendingly
     * @return list of items selected by city
     * @throws SlevnikException
     */
    public List<Item> findItemsByCity(String city, String sortingParam, Boolean ascending) throws SlevnikException;

    /**
     * This method finds list of all items sorted by distance to any city
     * @param city city used to calculate distances from all cities
     * @return list of items sorted by distance to given city
     * @throws SlevnikException
     */
    public List<Item> findItemsByDistanceToCity(String city) throws SlevnikException;

    /**
     * This method finds list of Items with text in title
     * @param text text to be found in Items titles
     * @param sortingParam parameter used to order Items
     * @param ascending boolean deciding if to sort ascendingly or descendingly
     * @return list of Items containing text in title
     * @throws SlevnikException
     */
    public List<Item> findItemsByText(String text, String sortingParam, Boolean ascending) throws SlevnikException;


}
